package com.qf.web.servlet;

import com.alibaba.fastjson.JSON;
import com.qf.pojo.GoodsType;
import com.qf.service.GoodsTypeService;
import com.qf.service.impl.GoodsTypeServiceImpl;

import javax.servlet.annotation.WebServlet;
import java.util.List;

/**
 * @author 千锋教育
 * @Company http://www.mobiletrain.org/
 * @Version 1.0
 */
@WebServlet("/goodstypeservlet")
public class GoodsTypeServlet extends BaseServlet {

    GoodsTypeService goodsTypeService = new GoodsTypeServiceImpl();

    public void goodstypelist(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws Exception {
        //查询一级分类列表
        List<GoodsType> goodsTypes = goodsTypeService.findTypeListByLevel(1);
        //把集合转换为json 字符串
        Object json = JSON.toJSON(goodsTypes);
        //返回到前端
        response.setCharacterEncoding("utf-8");
        response.getWriter().print(json);
    }
}
